/* process.h
	A class for holding process/thread related information in NACHOS
 */

#ifndef PROCESS_H
#define PROCESS_H

#include "bitmap.h"

#define MAX_PROCESSES 10
#define MAX_THREADS 50

class Thread;
class AddrSpace;
class Lock;

class Process {
	public:
		Process(char* debugName);
		Process(char* debugName, int processID, AddrSpace* addrSpace);
		~Process();

		void setProcessID(int processID);
		int getProcessID();

		void setAddrSpace(AddrSpace* addrSpace);
		AddrSpace* getAddrSpace();

		Thread* createThread(char* name);
		int addThread(Thread* thread);
		void removeThread(int threadID);
		int getThreadCount();
		Thread* getThread(int threadID);
		int getActiveThreadCount();
		void increaseActiveThreadCount();
		void decreaseActiveThreadCount();
		int getWaitThreadCount();
		void increaseWaitThreadCount();
		void decreaseWaitThreadCount();
		int getSignalThreadCount();
		void increaseSignalThreadCount();
		void decreaseSignalThreadCount();

		char* getName() { return (name); }

	private:
		char* name;
		int processID;
		AddrSpace* space;
		int threadCount;
		int activeThreadCount;
		int waitThreadCount;
		int signalThreadCount;
		Thread* threads[MAX_THREADS];
		BitMap* threadsMap;
		Lock* threadsMapLock;
};

#endif
